import os

# 读取文件并检查第1849行
def check_line(file_path, line_number):
    with open(file_path, 'r', encoding='utf-8') as f:
        lines = f.readlines()
    
    if line_number <= len(lines):
        line = lines[line_number - 1]  # 行号从1开始
        print(f"第{line_number}行内容:")
        print(repr(line))  # 使用repr显示不可见字符
        print(f"\n字符的十六进制表示:")
        for i, char in enumerate(line):
            print(f"位置{i}: {char!r} (0x{ord(char):02x})")
        
        # 检查前后几行
        start = max(0, line_number - 3)
        end = min(len(lines), line_number + 2)
        print(f"\n第{start+1}-{end}行的完整上下文:")
        for i in range(start, end):
            print(f"{i+1}: {lines[i]!r}")
    else:
        print(f"文件只有{len(lines)}行，无法检查第{line_number}行")

if __name__ == "__main__":
    file_path = "d:/未知/yolo_apply/video_processing/video_processor.py"
    check_line(file_path, 1849)